# 画出三种常见图形，需要分别执行各个代码块。
import numpy as np
import matplotlib.pyplot as plt

# 画两个正余弦函数图
x = np.arange(0,3*np.pi ,0.1)
y_sin = np.sin(x)
y_cos = np.cos(x)

plt.subplot(2,1,1)
plt.plot(x,y_sin)
plt.title("sine wave form")

plt.subplot(2,1,2)
plt.plot(x,y_cos)
plt.title("cosine wave form")

# 画条状图
x =  [5,8,10]
y =  [12,16,6]
x2 =  [6,9,11]
y2 =  [6,15,7]
plt.bar(x, y, align =  'center')
plt.bar(x2, y2, color =  'g', align =  'center')
plt.title('Bar graph')
plt.ylabel('Y axis')
plt.xlabel('X axis')

# 数据频率分布图形
a = np.array([22,87,5,43,56,73,55,54,11,20,51,5,79,31,27])
plt.hist(a, bins =  [0,20,40,60,80,100])
plt.title("histogram")

plt.show()
